package com.smartcampus.demo.controller;


import com.smartcampus.demo.domain.Humidity;
import com.smartcampus.demo.service.HumidityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/humidity")
public class HumidityController {

    @Autowired
    private HumidityService humidityService;

    @GetMapping
    public List<Humidity> getAllHumidity() {
        return humidityService.getAllHumidity();
    }

    @GetMapping("/{id}")
    public Humidity getHumidityById(@PathVariable Long id) {
        return humidityService.getHumidityById(id);
    }

    @GetMapping("/latest/{n}")
    public List<Humidity> getLatestHumidity(@PathVariable int n) {
        return humidityService.getLatestNHumidity(n);
    }
}
